Skip to content

Comments

feat(api): add rate-limited request layer with retry and circuit breaker#83

Merged
mijinummi merged 3 commits intoMDTechLabs:mainfrom
phertyameen:feat/rate-limitedRequestLayer
Feb 21, 2026
Merged

feat(api): add rate-limited request layer with retry and circuit breaker#83
mijinummi merged 3 commits intoMDTechLabs:mainfrom
phertyameen:feat/rate-limitedRequestLayer

Conversation

@phertyameen
Copy link
Contributor

@phertyameen phertyameen commented Feb 21, 2026

Summary

Introduces a resilient API layer between BridgeWise and all external upstream APIs, addressing rate limit failures surfaced during real-time quote refresh

Changes

  • rateLimitedApi.js — core client with token bucket, request queue, circuit breaker, and retry logic
  • Domain helpers as drop-in replacements for existing fetch calls
  • rateLimitedApi.test.js — full unit test coverage

Behaviour

  • Requests exceeding rateLimitPerSecond are delayed, not dropped
  • 429/5xx trigger retries with exponential backoff + jitter; Retry-After header is respected
  • Circuit opens after 5 failures, blocking requests until recovery timeout elapses
  • Non-retryable errors (4xx) surface immediately — no wasted retries

Testing

npx vitest rateLimitedApi.test.js

Closes #64

@mijinummi mijinummi merged commit 03e37be into MDTechLabs:main Feb 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚡ Implement Rate-Limited API Handling and Retry Mechanism

2 participants